perlping is a Unix-like ping(1) implementation, using Net::Ping for the low-level ping functionality. perlping was written because I wanted to install the Nagios network monitoring software on a client's hosted FreeBSD 4.8 system, but FreeBSD 4.8's built-in ping would not accept a ping count argument -- and Nagios needs a count-accepting ping to perform basic "host alive" checking.
perlping takes the following command-line arguments:
perlping defaults to connecting the HTTP (webserver) port 80 using TCP, which may be helpful in getting through firewalls that (justifiably) block ICMP packets. The ability to specify the protocol and port number is also useful for basic connectivity testing of other network services, like SSH.
perlping reports minimum, average, and maximum ping times, along with any packets lost. This functionality is sufficient for Nagios. If the standard deviation of ping response times was needed, you could easily add it using Statistics::Descriptive.
To install perlping, download the perlping source file, then type at the command line:
perl perlping-PL.TXT PERLPINGBINARYNAME
where PERLPINGBINARYNAME is the filename for your executable copy of perlping. (All the source program does is install perlping with the configured copy of Perl.)
perlping has been tested on FreeBSD 4.8, Windows XP, and Redhat Linux. It should work everywhere that Perl can use Net::Ping and command-line arguments. Enjoy!
The average time is computed as: (total of all received ping times) / (number of pings). This counts dropped packets as having responded in time 0 rather than either ignoring them or counting them as time infinity. I've seen a report saying min/max/average were 80/120/13.5 - an average of 13.5 calculated from a group of numbers in which the minimum was 80! The average should instead by computed as (total of all received ping times) / (number of received pings).
(Back when I was writing Math contests in high school, the coach would refer to this as "The average must be attained!" to summarize the collection of useful principles: (1) at least one of the numbers that were averaged must be less or equal than the average, (2) at least one must be greater or equal to the average, (3) if there is a number strictly less than the average, there must also be one that is strictly greater, and (4) if there is a number strictly greater than the average, there must also be one that is strictly less. Often a contest would include questions that were solved using that insight.)